package br.com.Orange.view.action.cliente;

import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import br.com.Orange.negocio.Fachada;
import br.com.Orange.negocio.cliente.model.Cliente;
import br.com.Orange.util.dados.exception.RepositorioVazioException;

public class ListarClienteAction extends Action {

	/* (non-Javadoc)
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception{
		
		Collection<Cliente> clientes;
		try {
			clientes = Fachada.obterInstancia().listarClientes();
			request.setAttribute("clientes", clientes);
		} catch (RepositorioVazioException e) {
			
		}
		
		return mapping.findForward("success");
		
	}
	
	

}
